package cn.iocoder.yudao.module.engine.model.websoket;

import cn.iocoder.yudao.module.engine.enums.EnumAudioType;
import cn.iocoder.yudao.module.engine.model.engine.EngineOutputData;
import cn.iocoder.yudao.module.resource.api.enums.MessageSourceTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.List;

@Data
public class EngineOutputDataVO {
    @Schema(description = "要播放的主音频")
    private EngineOutputDataVO.Audio mainAudio;

    @Schema(description = "辅助数据", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull
    private EngineOutputDataVO.AuxiliaryData auxiliaryData;

    @Schema(description = "传感器指令")
    private List<EngineOutputDataVO.SensorInstruction> sensorInstructions;

    /**
     * 音频
     */
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class Audio {
        @Schema(description = "单次聊天id", requiredMode = Schema.RequiredMode.REQUIRED)
        private String chatId;

        @Schema(description = "消息来源", requiredMode = Schema.RequiredMode.REQUIRED)
        private MessageSourceTypeEnum messageSendType;

        @Schema(description = "音频id", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotEmpty
        private String audioId;

        @Schema(description = "音频类型", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotNull
        private EnumAudioType audioType;

        @Schema(description = "音频描述", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotEmpty
        private String audioDesc;

        @Schema(description = "音频地址", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotEmpty
        private String audioUrl;

        @Schema(description = "关联类型，1 默认类型，2，回复类型")
        private int relationType;

        @Schema(description = "标签名称列表")
        private List<String> tagNameList;

        @Schema(description = "关键词名称列表")
        private List<String> keywordNameList;

        @Schema(description = "前缀音频")
        private EngineOutputData.Audio prefix;

        @Schema(description = "后缀音频")
        private EngineOutputData.Audio suffix;

        @Schema(description = "来自用户的消息")
        private String fromMessage;

        @Schema(description = "消息id")
        private String messageId;

        @Schema(description = "优先级")
        private Integer priority;
    }

    /**
     * 辅助数据
     */
    @Data
    public static class AuxiliaryData {
        @Schema(description = "播放间隔（毫秒）", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotNull
        private Integer playbackIntervalMs;

    }

    /**
     * 传感器指令
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class SensorInstruction {
        /**
         * 传感器类型
         */
        private String sensorType;

        /**
         * 操作类型
         */
        private String operationType;

        /**
         * 持续时间（秒）
         */
        private Integer durationSec;

        /**
         * 操作幅度
         */
        private BigDecimal step;

        /**
         * 扩展参数
         */
        private String extension;

        /**
         * 反馈音频
         */
        private Audio feedbackAudio;
    }

}
